from Bio.Seq import Seq
import unittest
import main

class Tests(unittest.TestCase):
    def __init__(self, *args, **kwargs):
        super(Tests, self).__init__(*args, **kwargs)
        self.file = "../../hometask-files/2-bio_toolkits/gene1.fasta"

    def test_empty_input(self):
        self.assertEqual(main.main([]), -1)

    def test_file_extensions(self):
        self.assertTrue(main.is_fasta("../../aaa/bbb.fasta"))
        self.assertFalse(main.is_gbk("../../aaa/bbb.fasta"))
        self.assertTrue(main.is_fasta("../../aaa/bbb.fa"))
        self.assertFalse(main.is_gbk("../../aaa/bbb.fa"))
        self.assertFalse(main.is_fasta("../../aaa/bbb.gbk"))
        self.assertTrue(main.is_gbk("../../aaa/bbb.gbk"))
        self.assertFalse(main.is_fasta("../../aaa/bbb.gb"))
        self.assertTrue(main.is_gbk("../../aaa/bbb.gb"))

    def test_reading(self):
        records = main.read_from_file(self.file)
        self.assertEqual(len(records), 1)
        self.assertEqual(records[0].id, "Bacteriophage")

    def test_gc_content(self):
        self.assertEqual(main.get_gc_content(Seq("ACGTACGT")), 50)

    def test_transcription(self):
        self.assertEqual(str(main.transcribe_sequence(Seq("ACGT"))), "ACGU")

    def test_translation(self):
        self.assertEqual(str(main.translate_sequence_to_seqrecord(Seq("GUGUCU"), "1").seq), "VS")

if __name__ == "__main__":
    unittest.main()

